<template>
  <view class="comparelist_container app_container_page">
    <appCompareItem v-for="item of list" :item="item" :key="item.contrastId" @COMPARE_ITEM_CLICK="handleItemClick" />
    <view v-if="list.length === 0" class="noData app_nodata"></view>
  </view>
</template>

<script>
import { getCompareList } from './api'
import appCompareItem from './components/app_compare_item'
export default {
  name: 'reportlist',
  components: {
    appCompareItem
  },
  data() {
    return {
      list: []
    }
  },
  methods: {
    async fetchList() {
      try {
        const res = await getCompareList()
        if (res.code === 200) {
          this.list = res.data
        }
      } catch (error) {
        console.log(error)
      }
    },
    handleItemClick(item) {
      // console.log(item)
      uni.navigateTo({
        url: `/pagesSub/compare/detail?id=${item.contrastId}`
      })
    }
  },
  onLoad(option) {
    //
    // this.fetchList()
  },
  onShow() {
    this.fetchList()
  }
}
</script>

<style lang="scss">
.comparelist_container {
  padding: 30rpx;
  background-image: url('#{$BASEURL}/bg-no-wave.png');
  background-size: contain;
  .noData {
    color: #ddd;
    text-align: center;
  }
}
</style>
